package com.tanhua.dubbo.api.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.domain.db.BlackList;
import com.tanhua.domain.db.UserInfo;
import com.tanhua.dubbo.api.BlackListApi;
import com.tanhua.dubbo.mapper.BlackListMapper;
import com.tanhua.dubbo.mapper.UserInfoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class BlackListApiImpl implements BlackListApi {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Autowired
    private BlackListMapper blackListMapper;

    @Override
    public IPage<UserInfo> findBlackList(Integer page, Integer pageSize, Long userId) {
        Page<UserInfo> params = new Page<UserInfo>(page,pageSize);
        return userInfoMapper.findBlackList(params, userId);
    }

    @Override
    public void deleteBlackList(BlackList blackList) {
        QueryWrapper<BlackList> query = new QueryWrapper<>();
        query.eq("user_id", blackList.getUserId());
        query.eq("black_user_id", blackList.getBlackUserID());
        blackListMapper.delete(query);
    }
}
